<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title>收货地址</title>
    <script src="/public/static/index/js/mui.min.js"></script>
    <link href="/public/static/index/css/mui.min.css" rel="stylesheet"/>
    <link rel="stylesheet" href="/public/static/index/css/iconfont.css" />
    <link rel="stylesheet" href="/public/index/css/style.css" />
    <link rel="stylesheet" href="__INDEX__/css/yund.css" />
</head>
<body>
	<header class="mui-bar mui-bar-nav">
	    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left" onclick="location.href='{:url('member/index')}'"></a>
	    <h1 class="mui-title">管理收货地址</h1>
	</header>
	<div class="mui-content">
	    <ul class="address_list" id="address_ul">
	    	{if $address_list==null||count($address_list)==0}
	    	<img src="__INDEX__/img/no.jpg"/> 
	    	{/if}
	    	{volist name='address_list' id='vo'}
	    	<li>
	    		<div class="address_top clearfix">
	    			<span class="address_name">{$vo.consignee}</span>
	    			<span class="address_call">{$vo.mobile}</span>
	    		</div>
	    		<div class="address_info">{$vo.address}</div>
	    		<div class="address_lisbtn clearfix">
	    			<div class="mui-input-row mui-checkbox mui-left">
						<label class="checked">默认地址</label>
						<input name="my_address" value="{$vo.id}" onchange="is_check('{$vo.id}')" type="checkbox" {if $vo.is_default==1}checked="checked"{/if}>
					</div>
					<div class="address_btnbox">
						<a href="{:url('member/address_update',['address_id'=>$vo.id])}"><span class="iconfont icon-bianji"></span>编辑</a>
						<a href="javascript:;" onclick="del_address('{$vo.id}')"><span class="iconfont icon-iconfontshanchu1"></span>删除</a>
					</div>
	    		</div>
	    	</li>
	    	{/volist}
	    </ul>	    
	</div>
	{if $address_list==null||count($address_list)==0}
	<a href="{:url('member/address_add')}" class="address_addbtn" id="add_dizhi">添加新地址</a>
	{/if}
</body>
</html>
{include file="public/footer" /}
<script>
	function is_check(id){
		layer.confirm('您确定要修改吗？', {
			btn: ['确定', '取消'] //按钮
		}, function() {
			$("input[name='my_address']").removeAttr("checked"); 
			$.ajax({
				type:"post",
				url: "{:url('index/member/address_default')}",
				data: {address_id:id},//表单数据
				success: function(data) {
					layer.msg(data.msg, {
					  icon: 1,
					  time: 1500 //2秒关闭（如果不配置，默认是3秒）
					}, function(){
						  if(data.code == 200) {
								location.reload();
						  }
					}); 
				}
			})
		})
	}
	
	
	function del_address(id){
		layer.confirm('您确定要删除吗？', {
			btn: ['确定', '取消'] //按钮
		}, function() {
			$.ajax({
				type:"post",
				url: "{:url('index/member/address_del')}",
				data: {address_id:id},//表单数据
				success: function(data) {
					layer.msg(data.msg, {
					  icon: 1,
					  time: 1500 //2秒关闭（如果不配置，默认是3秒）
					}, function(){
						  if(data.code == 200) {
								location.reload();
						  }
					}); 
				}
			})
		})
	}
	
	
</script>
